package org.asg.dis.service;

import org.asg.dis.model.ComplaintResponse;
import org.asg.dis.repository.ComplaintResponseRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComplaintResponseService {

    @Autowired
    private ComplaintResponseRepo complaintResponseRepository;

    // 查询某个投诉的所有回复
    public List<ComplaintResponse> getResponsesByComplaintId(Long complaintId) {
        return complaintResponseRepository.findByComplaint_ComplaintId(complaintId);
    }

    // 查询某个处理人员的所有回复
    public List<ComplaintResponse> getResponsesByProcessorId(Long processorId) {
        return complaintResponseRepository.findByProcessor_UserId(processorId);
    }

    // 保存投诉回复
    public ComplaintResponse saveComplaintResponse(ComplaintResponse complaintResponse) {
        return complaintResponseRepository.save(complaintResponse);
    }

    public void save(ComplaintResponse response) {
        complaintResponseRepository.save(response);
    }
}
